/*-------------------------------------------------------------------------
 *
 * pg_range.h
 *	  "范围类型" 系统目录 (pg_range) 的定义
 *
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/catalog/pg_range.h
 *
 * NOTES
 *	  Catalog.pm 模块读取此文件并推导模式信息。
 *
 *-------------------------------------------------------------------------
 */
#ifndef PG_RANGE_H
#define PG_RANGE_H

#include "catalog/genbki.h"
#include "catalog/pg_range_d.h"

/* ----------------
 *		pg_range 定义。 cpp 将其转换为
 *		typedef struct FormData_pg_range
 * ----------------
 */
CATALOG(pg_range,3541,RangeRelationId)
{
	/* 拥有范围类型的 OID */
	Oid			rngtypid BKI_LOOKUP(pg_type);

	/* 范围元素类型（子类型）的 OID */
	Oid			rngsubtype BKI_LOOKUP(pg_type);

	/* 范围的多范围类型的 OID */
	Oid			rngmultitypid BKI_LOOKUP(pg_type);

	/* 此范围类型的排序规则，或 0 */
	Oid			rngcollation BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_collation);

	/* 子类型的 btree opclass */
	Oid			rngsubopc BKI_LOOKUP(pg_opclass);

	/* 规范化范围，或 0 */
	regproc		rngcanonical BKI_LOOKUP_OPT(pg_proc);

	/* 子类型差异作为 float8，或 0 */
	regproc		rngsubdiff BKI_LOOKUP_OPT(pg_proc);
} FormData_pg_range;

/* ----------------
 *		Form_pg_range 对应指向一个与
 *		pg_range 关系格式相符的元组的指针。
 * ----------------
 */
typedef FormData_pg_range *Form_pg_range;

DECLARE_UNIQUE_INDEX_PKEY(pg_range_rngtypid_index, 3542, RangeTypidIndexId, on pg_range using btree(rngtypid oid_ops));
DECLARE_UNIQUE_INDEX(pg_range_rngmultitypid_index, 2228, RangeMultirangeTypidIndexId, on pg_range using btree(rngmultitypid oid_ops));

/*
 * pg_range.c 中函数的原型
 */

extern void RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation,
						Oid rangeSubOpclass, RegProcedure rangeCanonical,
						RegProcedure rangeSubDiff, Oid multirangeTypeOid);
extern void RangeDelete(Oid rangeTypeOid);

#endif							/* PG_RANGE_H */
